package com.huel.components;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.huel.bean.Btn;
import com.huel.bean.Phone;
import com.huel.taobaostore.R;

import java.util.List;

public class MyPhoneRecyclerViewAdapter extends RecyclerView.Adapter<MyPhoneRecyclerViewAdapter.ViewHolder> {
    private List<Phone> mList;
    @NonNull
    @Override
    public MyPhoneRecyclerViewAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        //绑定 phone 页面
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_phone,null);
        final MyPhoneRecyclerViewAdapter.ViewHolder holder = new MyPhoneRecyclerViewAdapter.ViewHolder(view);
        return holder;

    }

    @Override
    public void onBindViewHolder(@NonNull MyPhoneRecyclerViewAdapter.ViewHolder holder, int position) {
        Phone bean = mList.get(position);
        holder.title.setText(bean.getName());
        holder.tel.setText(bean.getTel());

    }

    @Override
    public int getItemCount() {
        return mList.size();
    }


    public MyPhoneRecyclerViewAdapter(List<Phone> mList) {
        this.mList = mList;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        View myView;
        ImageView imageView,show;
        TextView title,tel;
        public ViewHolder(View itemView) {
            super(itemView);
            myView = itemView;
            show=itemView.findViewById(R.id.show);
            title =itemView.findViewById(R.id.tv_title01);
            tel = itemView.findViewById(R.id.tv_time01);
        }
    }


}
